package com.gao.volatiletest;

import java.util.concurrent.TimeUnit;

public class JmmDemo {
    private static int num = 0;
//    private volatile static int num = 0;
//    main线程
    public static void main(String[] args) throws InterruptedException {
//        线程1 对主内存的变化是不知道的
        new Thread( () -> {
            while (num == 0){

            }
        }).start();

        TimeUnit.SECONDS.sleep(1);

        num = 1;
        System.out.println(num);

    }
}
